package com.kclm.xsap.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Past;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("t_member")
@Accessors(chain = true)
public class MemberEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    
    @TableId
    private Long id;
    
    @NotBlank(message = "用户名不能为空")
    private String name;
    
    @NotBlank(message = "性别不能为空")
    private String sex;
    
    @NotBlank(message = "用户手机号码不能为空")
    private String phone;
    
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Past(message = "用户出生日期不需要在今天之间")
    private LocalDate birthday;
    
    private String note;
    
    private String avatarUrl;
    
    @TableLogic
    private Integer isDeleted;
    
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime lastModifyTime;

    @Version
    private Integer version;

}
